var wDetail = function(){
	
	Ti.include('tmp.js');
	
	this.dNews = function(pTitle, jData){
		var vNews = Ti.UI.createScrollView({
		    contentHeight: 'auto',
			showVerticalScrollIndicator: true,
			top: 44,
			height: 365,
			zindex: 999,
		})

		var mHero = Ti.UI.createImageView({
			image: getCorrectFile(jData.img + "2.jpg"),
			top: 0,
			width: 320,
			height: 214,	
		})
		
		var mContent = Ti.UI.createLabel({
			top: 214,
			left: 5,
			width: 310,
		    height:'auto',
			font: {fontSize: 14},
			color: "white",
			textAlign: "left",
			text: jData.text,
		})
		
		if(jData.text.length > 100){
			mContent.height = "auto";
		}
		
	 	
	 	var btnShare = Titanium.UI.createButton({
			image: "media/nav/btn_share.png",
			top: 10,
			width: 54,
			height: 25,
			right: 15,	
				
		})			
		btnShare.addEventListener('click', function(e){
			var shareArray = ['', jData.text, mHero.toImage(), ''];
			var hs = new hShare();
			hs.sinaShare(shareArray);
		})
	 	
	 	vNews.add(mHero);
	 	vNews.add(mContent);
	 	
		tW = tmpWin(pTitle, 'detail');
		tW.add(vNews);
		tW.add(btnShare);
		tW.open();
		
		
	}
	
	this.dCoverflow = function(){
		
		var coverflowView = Titanium.UI.createView({
			top: 0,
			width: 320,
			height: 367,
			backgroundImage: "media/images/bgimage.png",
		});
		var coverImageView = Titanium.UI.createCoverFlowView({
			backgroundColor: "transparent",
			zIndex: 99,
		});
		
		coverflowView.add(coverImageView);
		dataSource('images', coverImageView);
		
		
		return coverflowView;
	}

	this.dWeibo = function(pWeibo){
		
		var vView = Ti.UI.createScrollView({
		    contentHeight: 'auto',
			showVerticalScrollIndicator: true,
			top: 44,
			height: 366,
			zindex: 999,
			backgroundColor: 'white',
		})
			
		var weiboText = Titanium.UI.createLabel({
			text: pWeibo.text,
			font: {fontSize: 14, fontColor: "white"},
			top: 20,
			left: 10,
			width: 300,
			height: "auto",
			textAlign: "left",
		});
		vView.add(weiboText);
		
		var vWeiboRTime = Titanium.UI.createView({
			top: weiboText.height+40,
		})
		
		var weiboRT = Titanium.UI.createLabel({
			font: {fontSize: 10},
			top: 0,
			right: 20,
			height: 10,
			width: 100,
			textAlign: "right",
		})
		vWeiboRTime.add(weiboRT);
		var weiboCreated = new Date(pWeibo.created_at);
		var wC = weiboCreated.getMonth()+"月"+weiboCreated.getDate()+"日 "+weiboCreated.getHours()+":"+weiboCreated.getMinutes();
		
		var weiboTime = Titanium.UI.createLabel({
			font: {fontSize: 10},
			top: 0,
			left: 10,
			height: 10,
			width: 100,
			text: wC,
			textAlign: "left",
		})
		vWeiboRTime.add(weiboTime);
		
		vView.add(vWeiboRTime);
		
		if(pWeibo.bmiddle_pic){
			var weiboPic =  Titanium.UI.createImageView({
				image: pWeibo.bmiddle_pic,
				top: weiboText.height + 30,
				height: 128,
				width: 128,
				left: 10,
			});
			vWeiboRTime.top = weiboText.height + 128 + 40;
			vView.add(weiboPic);
		}
		
		var jLoader = Ti.Network.createHTTPClient();	
		jLoader.onload = function(e) {
			if (jLoader.status == 200) {
				RT = JSON.parse(jLoader.responseData)[0];
				weiboRT.text = "转发:"+RT.rt+" | 评论:"+RT.comments;
				
			}else{
				errorMSG("远程服务器无法响应，请稍后再试。");
				
			}
		};
		jLoader.open('GET', 'http://api.t.sina.com.cn/statuses/counts.json?source=2424068513&ids='+pWeibo.id);
		jLoader.send();


		if(pWeibo.retweeted_status){
	
			var reWeibo = pWeibo.retweeted_status;
				
			var vReWeibo = Titanium.UI.createView({
				top: weiboText.height + 80,
				backgroundColor: "#ccc",
				borderColor: "#ccc",
				width: 260,
				height: "auto",
			})
			var reWeiboText = Titanium.UI.createLabel({
				text: reWeibo.text,
				font: {fontSize: 14, fontColor: "white"},
				top: 0,
				height: "auto",
				textAlign: "left"
			});
			vReWeibo.add(reWeiboText);
			
			if(reWeibo.bmiddle_pic){
				if(reWeiboText.text.length < 20){
					h = 30;
				}else{
					h = reWeiboText.text.length;
				}
				var reWeiboPic =  Titanium.UI.createImageView({
					image: reWeibo.bmiddle_pic,
					top:  h,
					width: 128,
					height: 128,
				});
				vReWeibo.add(reWeiboPic);
			}
			
			vView.add(vReWeibo);
			
		}
		
		
		
		tW = tmpWin("weibo", "detail");
		var btnShare = Ti.UI.createButton({
			image: "media/nav/btn_share.png",
			top: 10,
			width: 54,
			height: 25,
			right: 15,
			
		})	
		btnShare.addEventListener('click', function(e){
			var shareArray = [pWeibo.id, '转发微博', '', ''];
			var hs = new hShare();
			hs.sinaShare(shareArray);
			
		})
		
		tW.add(vView);
		tW.add(btnShare);
		tW.open();
		
	}
	
	this.dMore = function(){
		var vMore = Ti.UI.createView({
			top: 0,
			width: 320,
			height: 367,
			backgroundImage: 'media/images/bgmore.png',
		})
			
		var mInfo =  Titanium.UI.createImageView({
			top:  30,
			width: 288,
			height: "auto"
		});
		vMore.add(mInfo);
		
		dataSource('more', mInfo);
		
		return vMore;
	}
	
}